package com.megvii.koala.tv.adapter;

import android.content.Context;
import android.widget.TextView;

import com.megvii.corelib.base.MegviiAdapter;
import com.megvii.koala.tv.R;
import com.megvii.koala.tv.data.CameraBean;

import java.util.List;

import butterknife.Bind;

/**
 * Created by linyue on 16/3/16.
 */
public class DisplayCameraSettingAdapter
        extends MegviiAdapter<DisplayCameraSettingAdapter.ViewHolder>
{
    private List<CameraBean> cameras;

    public DisplayCameraSettingAdapter(Context context)
    {
        super(context, ViewHolder.class, R.layout.camera_item);
    }

    public void updateData(List<CameraBean> cameras)
    {
        this.cameras = cameras;
        notifyDataSetChanged();
    }

    @Override
    protected void processViewHolder(ViewHolder viewHolder, int position)
    {
        CameraBean camera = cameras.get(position);
        viewHolder.addressText.setText(camera.camera_position + "(" + camera.camera_address + ")");
    }

    @Override
    public int getCount()
    {
        return cameras != null ? cameras.size() : 0;
    }

    @Override
    public Object getItem(int position)
    {
        return cameras.get(position);
    }

    @Override
    public long getItemId(int position)
    {
        return 0;
    }

    public static class ViewHolder
    {
        @Bind(R.id.camera_item_address)
        public TextView addressText;
    }
}
